﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataSkipOperations" @search="getTableDataSkipOperations">
      <el-row>
        
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Snnumber_FormItem" prop="Snnumber" label="SN">
            <el-input v-model="searchDataSkipOperations.Snnumber" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OperationCode_FormItem" prop="OperationCode" label="工序编码">
            <el-input v-model="searchDataSkipOperations.OperationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OperationId_FormItem" prop="OperationId" label="工序ID">
            <el-input v-model="searchDataSkipOperations.OperationId" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OperationName_FormItem" prop="OperationName" label="工序名称">
            <el-input v-model="searchDataSkipOperations.OperationName" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OrderCode_FormItem" prop="OrderCode" label="工单编号">
            <el-input v-model="searchDataSkipOperations.OrderCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OrderId_FormItem" prop="OrderId" label="工单ID">
            <el-input v-model="searchDataSkipOperations.OrderId" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="IsSkip_FormItem" prop="IsSkip" label="是否跳站">
            <el-select v-model="searchDataSkipOperations.IsSkip" clearable>
                <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
                <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
                </el-select>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="AddTime_FormItem" prop="AddTime" label="添加时间">
            <el-date-picker v-model="searchDataSkipOperations.AddTime" clearable></el-date-picker>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="EditTime_FormItem" prop="EditTime" label="编辑时间">
            <el-date-picker v-model="searchDataSkipOperations.EditTime" clearable></el-date-picker>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="LastOperationCode_FormItem" prop="LastOperationCode" label="前工序编码">
            <el-input v-model="searchDataSkipOperations.LastOperationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="LineCode_FormItem" prop="LineCode" label="产线编码">
            <el-input v-model="searchDataSkipOperations.LineCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="NextNode_FormItem" prop="NextNode" label="下一个节点">
            <el-input v-model="searchDataSkipOperations.NextNode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="NextOperationCode_FormItem" prop="NextOperationCode" label="后工序编码">
            <el-input v-model="searchDataSkipOperations.NextOperationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="NextOperationId_FormItem" prop="NextOperationId" label="后工序ID">
            <el-input v-model="searchDataSkipOperations.NextOperationId" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ParentOperationCode_FormItem" prop="ParentOperationCode" label="父工序编码">
            <el-input v-model="searchDataSkipOperations.ParentOperationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ParentOperationId_FormItem" prop="ParentOperationId" label="父工序ID">
            <el-input v-model="searchDataSkipOperations.ParentOperationId" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="RouteName_FormItem" prop="RouteName" label="工艺路线名称">
            <el-input v-model="searchDataSkipOperations.RouteName" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="RouteNumber_FormItem" prop="RouteNumber" label="工艺路线编号">
            <el-input v-model="searchDataSkipOperations.RouteNumber" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="RouteVersion_FormItem" prop="RouteVersion" label="工艺路线版本">
            <el-input v-model="searchDataSkipOperations.RouteVersion" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ScheduleNumber_FormItem" prop="ScheduleNumber" label="排程编号">
            <el-input v-model="searchDataSkipOperations.ScheduleNumber" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Sort_FormItem" prop="Sort" label="排序">
            <el-input v-model="searchDataSkipOperations.Sort" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="IsValid_FormItem" prop="IsValid" label="是否有效">
            <el-select v-model="searchDataSkipOperations.IsValid" clearable>
                <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
                <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
                </el-select>
        </el-form-item>
    </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/SkipOperations/Add'" icon='fa fa-plus' type='primary' :button-text="$t('message._system.common.vm.add')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/SkipOperations/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message._system.common.vm.batchdelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/SkipOperations/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message._system.common.vm.import')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/SkipOperations/SkipOperationsExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message._system.common.vm.export')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefSkipOperations" v-bind="tableDataSkipOperations">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
          <el-button text type="primary" @click="OnEditrowClick(scope.row)" v-auth="'/api/SkipOperations/Edit'">{{ $t('message._system.common.vm.edit') }}</el-button>
					<el-button text type="primary" @click="OnDetailsrowClick(scope.row)" v-auth="'/api/SkipOperations/{id}'">{{ $t('message._system.common.vm.detail') }}</el-button>
					<el-popconfirm :title="$t('message._system.common.vm.deletetip')"  @confirm="onDelete(scope.row)">
						<template #reference>
							<el-button text type="danger" v-auth="'/api/SkipOperations/BatchDelete'">{{ $t('message._system.common.vm.delete') }}</el-button>
						</template>
					</el-popconfirm>
        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="跳站记录;true;TyMES.Controllers;SkipOperations">
import {  ElMessageBox, ElMessage } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { SkipOperationsApi } from '/@/api/record/SkipOperations';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateSkipOperations = reactive({
    
});

const searchDataSkipOperations = ref({
    			Snnumber: null,
			OperationCode: null,
			OperationId: null,
			OperationName: null,
			OrderCode: null,
			OrderId: null,
			IsSkip: null,
			AddTime: null,
			EditTime: null,
			LastOperationCode: null,
			LineCode: null,
			NextNode: null,
			NextOperationCode: null,
			NextOperationId: null,
			ParentOperationCode: null,
			ParentOperationId: null,
			RouteName: null,
			RouteNumber: null,
			RouteVersion: null,
			ScheduleNumber: null,
			Sort: null,
			IsValid: null,

});

// 定义变量内容
const tableRefSkipOperations = ref();
const tableDataSkipOperations = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
  
        {title:'SN',key: 'Snnumber',type: 'text',isCheck: true},
        {title:'工序编码',key: 'OperationCode',type: 'text',isCheck: true},
        {title:'工序ID',key: 'OperationId',type: 'text',isCheck: true},
        {title:'工序名称',key: 'OperationName',type: 'text',isCheck: true},
        {title:'工单编号',key: 'OrderCode',type: 'text',isCheck: true},
        {title:'工单ID',key: 'OrderId',type: 'text',isCheck: true},
        {title:'是否跳站',key: 'IsSkip',type: 'switch',isCheck: true},
        {title:'添加时间',key: 'AddTime',type: 'text',isCheck: true},
        {title:'编辑时间',key: 'EditTime',type: 'text',isCheck: true},
        {title:'前工序编码',key: 'LastOperationCode',type: 'text',isCheck: true},
        {title:'产线编码',key: 'LineCode',type: 'text',isCheck: true},
        {title:'下一个节点',key: 'NextNode',type: 'text',isCheck: true},
        {title:'后工序编码',key: 'NextOperationCode',type: 'text',isCheck: true},
        {title:'后工序ID',key: 'NextOperationId',type: 'text',isCheck: true},
        {title:'父工序编码',key: 'ParentOperationCode',type: 'text',isCheck: true},
        {title:'父工序ID',key: 'ParentOperationId',type: 'text',isCheck: true},
        {title:'工艺路线名称',key: 'RouteName',type: 'text',isCheck: true},
        {title:'工艺路线编号',key: 'RouteNumber',type: 'text',isCheck: true},
        {title:'工艺路线版本',key: 'RouteVersion',type: 'text',isCheck: true},
        {title:'排程编号',key: 'ScheduleNumber',type: 'text',isCheck: true},
        {title:'排序',key: 'Sort',type: 'text',isCheck: true},
        {title:'是否有效',key: 'IsValid',type: 'switch',isCheck: true},
	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataSkipOperations = () => {
    tableRefSkipOperations.value.doSearch(SkipOperationsApi().search, searchDataSkipOperations.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.add'), CreateDialog, null, getTableDataSkipOperations)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.edit'), EditDialog, row, getTableDataSkipOperations)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.detail'), DetailsDialog, row, getTableDataSkipOperations)
};

// 删除
const onDelete = (row: any) => {
    SkipOperationsApi().delete([row.ID]).then(() => { getTableDataSkipOperations()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefSkipOperations.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      SkipOperationsApi().delete(selectedids).then(() => { getTableDataSkipOperations()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.import'), ImportDialog, null, getTableDataSkipOperations)
};

const onExport = () => {
	const selected = tableRefSkipOperations.value.getSelectedRows();
	if (selected.length > 0) {
		SkipOperationsApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		SkipOperationsApi().export({});
	}
};

// 页面加载时
onMounted(() => {
     
        getTableDataSkipOperations();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

